<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
    <title>react</title>
</head>

<body>
    <!-- 准备好一个容器 -->
    <div class="test"></div>
    <div class="test2"></div>

    <!-- js按顺序引入 -->
    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../js/react.development.js"></script>

    <!-- 引入react-dom,用于操作dom -->
    <script type="text/javascript" src="../js/react-dom.development.js"></script>

    <!-- 引入babel,用于将jsx转为js -->
    <script type="text/javascript" src="../js/babel.min.js"></script>

    <!-- 引入prop-types,用于对组件标签进行限制 -->
    <script type="text/javascript" src="../js/prop-types.js"></script>

    <script type="text/babel">
        // 1.创建类式组件 组件名首字母必须大写
        class Demo extends React.Component{    
      //      React.createRef调用后可以返回一个容器，该容器可以存储被ref所标识的节点,该容器专人专用
            myRef = React.createRef()
            myRef2 = React.createRef()
            shoWData= ()=>{

                console.log(this.myRef.current.value);
            }
            shoWData2= ()=>{

console.log(this.myRef2.current.value);
}
            render(){
                const {name,sex,age } =this.props
                return (
                    <div>
                    <input ref={this.myRef} type='text' placeholder='点击按钮提示数据'/> 
               <button onClick={this.shoWData}>按钮</button>
               
               <input ref={this.myRef2} type='text' placeholder='点击按钮提示数据'/> 
               <button onClick={this.shoWData2}>按钮</button>
               

               </div>
                    )
            }
        }
 
    
      // 2.渲染虚拟Dom 
      ReactDOM.render(<Demo name="李文清" sex='男' age={21} />, document.querySelector(".test"));
    </script>
</body>
<style>

</style>

</html>